package com.lanyou.esb.cook.proxy.entity;

import java.util.Calendar;
import java.util.Date;

import org.apache.commons.lang3.StringUtils;

import com.lanyou.esb.cook.proxy.common.Constants;
import com.lanyou.esb.cook.proxy.meta.EnableType;

/**
 * 接口访问次数
 * 
 * @author Davey.wu
 */
public class IfAccTimes {
	/** 领域ID **/
	private String fieldId;
	/** 系统ID **/
	private String systemId;
	/** 接口ID **/
	private String ifId;
	/** 接口名称 **/
	private String ifName;
	/** 次数 **/
	private int times;
	/** 统计时间 **/
	private Date statDate;

	/** 是否可用 **/
	private String isEnable;
	/** 创建人 **/
	private String creator;
	/** 创建时间 **/
	private Date createDate;
	/** 最后更新人员 **/
	private String modifier;
	/** 最后更新时间 **/
	private Date lastUpDate;

	public IfAccTimes() {
		this.isEnable = EnableType.ENABLE.ValueCode;
	}

	public String getFieldId() {
		return fieldId;
	}

	public IfAccTimes setFieldId(String fieldId) {
		this.fieldId = fieldId;
		return this;
	}

	public String getSystemId() {
		return systemId;
	}

	public IfAccTimes setSystemId(String systemId) {
		this.systemId = systemId;
		return this;
	}

	public String getIfName() {
		return ifName;
	}

	public IfAccTimes setIfName(String ifName) {
		this.ifName = ifName;
		return this;
	}

	public int getTimes() {
		return times;
	}

	public IfAccTimes setTimes(int times) {
		this.times = times;
		return this;
	}

	public Date getStatDate() {
		if (statDate == null) {
			statDate = new Date();
		}
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(statDate);
		calendar.set(Calendar.HOUR_OF_DAY, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MILLISECOND, 0);
		this.statDate = calendar.getTime();
		return statDate;
	}

	public IfAccTimes setStatDate(Date statDate) {
		this.statDate = statDate;
		return this;
	}

	public String getIfId() {
		return ifId;
	}

	public IfAccTimes setIfId(String ifId) {
		this.ifId = ifId;
		return this;
	}

	public String getIsEnable() {
		return isEnable;
	}

	public void setIsEnable(String isEnable) {
		this.isEnable = isEnable;
	}

	public String getCreator() {
		return StringUtils.isEmpty(creator) ? Constants.DEFAULT_USER : creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public Date getCreateDate() {
		return createDate == null ? new Date() : createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getModifier() {
		return StringUtils.isEmpty(modifier) ? Constants.DEFAULT_USER
				: modifier;
	}

	public void setModifier(String modifier) {
		this.modifier = modifier;
	}

	public Date getLastUpDate() {
		return lastUpDate;
	}

	public void setLastUpDate(Date lastUpDate) {
		this.lastUpDate = lastUpDate;
	}

}